﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Buca.Application.aBigTime.Presenter.Dictionary.BudgetSourceProperty;
using Buca.Application.aBigTime.View.Dictionary;
using Buca.Application.aBigTime.WindowsForm.FormBase;
using Buca.Application.aBigTime.WindowsForm.Resources;
using DevExpress.XtraEditors;

namespace Buca.Application.aBigTime.WindowsForm.FormDictionary
{
    public partial class FrmBudgetSourcePropertyDetail : FrmBaseCategoryDetail, IBudgetSourcePropertyView
    {
        private BudgetSourcePropertyPresenter _budgetSourcePropertyPresenter;

        #region Properties

        /// <summary>
        /// Gets or sets the budget source property identifier.
        /// </summary>
        /// <value>
        /// The budget source property identifier.
        /// </value>
        public int BudgetSourcePropertyID { get; set; }
        /// <summary>
        /// Gets or sets the budget source property code.
        /// </summary>
        /// <value>
        /// The budget source property code.
        /// </value>
        public string BudgetSourcePropertyCode
        {
            get { return txtBudgetSourcePropertyCode.Text; }
            set { txtBudgetSourcePropertyCode.Text = value; }
        }
        /// <summary>
        /// Gets or sets the name of the budget source property.
        /// </summary>
        /// <value>
        /// The name of the budget source property.
        /// </value>
        public string BudgetSourcePropertyName
        {
            get { return txtBudgetSourcePropertyName.Text; }
            set { txtBudgetSourcePropertyName.Text = value; }
        }
        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>
        /// The description.
        /// </value>
        public string Description
        {
            get { return memoDescription.Text; }
            set { memoDescription.Text = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether [is active].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [is active]; otherwise, <c>false</c>.
        /// </value>
        public bool IsActive
        {
            get { return chkIsActive.Checked; }
            set { chkIsActive.Checked = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether [is system].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [is system]; otherwise, <c>false</c>.
        /// </value>
        public bool IsSystem { get; set; }

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="FrmBudgetSourcePropertyDetail"/> class.
        /// </summary>
        public FrmBudgetSourcePropertyDetail()
        {
            InitializeComponent();
            _budgetSourcePropertyPresenter = new BudgetSourcePropertyPresenter(this);
        }
        /// <summary>
        /// Initializes the data.
        /// </summary>
        protected override void InitData()
        {
            if (KeyValue != null)
                _budgetSourcePropertyPresenter.Display(KeyValue);
        }
        /// <summary>
        /// Valids the data.
        /// </summary>
        /// <returns></returns>
        protected override bool ValidData()
        {
            if (string.IsNullOrEmpty(BudgetSourcePropertyCode))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResBudgetSourcePropertyCode"),
                                ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtBudgetSourcePropertyCode.Focus();
                return false;
            }
            if (string.IsNullOrEmpty(BudgetSourcePropertyName))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResBudgetSourcePropertyName"),
                                ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtBudgetSourcePropertyName.Focus();
                return false;
            }
            return true;
        }
        /// <summary>
        /// Saves the data.
        /// </summary>
        /// <returns></returns>
        protected override int SaveData()
        {
            return _budgetSourcePropertyPresenter.Save();
        }
        /// <summary>
        /// Focuses the control.
        /// </summary>
        protected override void InitControls()
        {
            txtBudgetSourcePropertyCode.Focus();
        }
    }
}
